{% load i18n %}
{% load lfs_tags %}

{% if show %}
    <div class="filtered-navigation-portlet portlet">

        <div class="portlet-header">
            {{ title }} <a href="{% url lfs_reset_all_product_filter category.slug %}">[x]</a>
        </div>

        <div class="portlet-body">
            {% if show_product_filters %}
                {% for property_group in product_filters %}
                    {% if property_group.items %}
                        <div class="portlet-item">
                            <div class="filter-title {% if forloop.first %}first{% endif %}">
                                <span>
                                    {{ property_group.title }}
                                </span>
                                {% if property_group.show_reset %}
                                    <a href="{% url lfs_reset_product_filter category.slug property_group.id %}">[x]</a>
                                {% endif %}
                            </div>
                            {% for property in property_group.items %}
                                <div>
                                    {% if property_group.object.is_number_field %}
                                        {% if property_group.show_quantity %}
                                            <a href='{% url lfs_set_product_filter category.slug property_group.id property.min property.max %}'>
                                                {{ property.min|quantity }} - {{ property.max|quantity }} {{ property_group.unit|safe }} ({{ property.quantity }})
                                            </a>
                                        {% else %}
                                            <span>
                                                {{ property.min|quantity }} - {{ property.max|quantity }} {{ property_group.unit|safe }}
                                            </span>
                                        {% endif %}
                                    {% else %}
                                        {% if property.show_quantity %}
                                            <a href='{% url lfs_set_product_filter category.slug property_group.id property.value %}'>
                                                {{ property.name }} {{ property_group.unit|safe }} ({{ property.quantity }})
                                            </a>
                                        {% else %}
                                            <span>
                                                {{ property.name }} {{ property_group.unit|safe }}
                                            </span>
                                        {% endif %}

                                    {% endif %}
                                </div>
                            {% endfor %}
                        </div>
                    {% endif %}
                {% endfor %}
            {% endif %}

            {% if show_price_filters %}
                <div class="portlet-item">

                    <div class="filter-title">
                        <span>{% trans 'Price' %}</span>
                        {% if price_filters.show_reset %}
                            <a href="{% url lfs_reset_price_filter category.slug %}">[x]</a>
                        {% endif %}
                    </div>

                    {% for price_filter in price_filters.items %}
                        <div>
                            {% if price_filters.show_quantity %}
                                <a href="{% url lfs_set_price_filter category.slug %}?min={{ price_filter.min }}&amp;max={{ price_filter.max }}">
                                    {% trans 'Up to' %} {{ price_filter.max|decimal_l10n }}
                                    ({{ price_filter.quantity }})
                                </a>
                            {% else %}
                                <span>
                                    {% trans 'Up to' %} {{ price_filter.max|currency:request }}
                                </span>
                            {% endif %}
                        </div>
                    {% endfor %}
                </div>
                {# <form action="{% url lfs_set_price_filter category.slug %}" #}
                {#       method="post">         #}
                {#     <div> #}
                {#         <label>{% trans 'From' %}</label> #}
                {#         <input type="text" #}
                {#                name="min" #}
                {#                value="{{ price_filter.min }}" #}
                {#                size="10" /> #}
                {#     </div>                    #}
                {#     <div> #}
                {#         <label>{% trans 'To' %}</label> #}
                {#         <input type="text" #}
                {#                name="max"  #}
                {#                value="{{ price_filter.max }}" #}
                {#                size="10" />                                           #}
                {#     </div>        #}
                {#     <div> #}
                {#         <input type="submit" #}
                {#                value="{% trans 'Go!' %}" /> #}
                {#     </div> #}
                {# </form> #}
            {% endif %}
        </div>

        <div class="portlet-footer">
            <a href="{% url lfs_reset_all_product_filter category.slug %}">
                {% trans 'Reset all filters' %}
            </a>
        </div>
    </div>
{% endif %}
